<?php

require_once APPLICATION_PATH.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'Component_Abstract.php';
class Galleria extends Component_Abstract  {

	private $_galleria;
        private $_galleryTitle;

        public function setGalleryTitle($data) {
            $this->_galleryTitle=$data;
            return $this;
        }

        public function getGalleryTitle() {
            return $this->_galleryTitle;
        }
    
        public function setGalleria($data) {
            $this->_galleria=$data;
        }
        
        public function getGalleria() {
            return $this->_galleria;
        }


        public function initComponent() {
            
        }

	public function show() {

            $groupId = $this->getParameter('group_id');
            if (is_null($groupId))
                    throw new Exception("group_id is null");
            $imageGroup = new Default_Model_ImageGroups();
            $imageGroup->find($groupId);
            $galleryTitle=$imageGroup->getTitle();
            $this->setGalleryTitle($galleryTitle);

            $image = new Default_Model_Images();
            $rows=$image->getImagesByGroupId($groupId);
            foreach ($rows as &$row)
                $row['src']=$this->getImagesUri().'/'.$imageGroup->getPath().'/'.$row['filename'];
            $this->setGalleria($rows);
            $ret=$this->getTmplContent($this->getConfig()->phtml->mainpage);
            return $ret;

	}

        public function demo() {
            $ret=$this->getTmplContent($this->getConfig()->phtml->demopage);
            return $ret;
        }

        public function getConfigPage() {

            return false;
            
        }

        public function getOptionsDiv() {

            $ret=$this->getTmplContent($this->getConfig()->phtml->optionspage);
            return $ret;

        }


}
